|
|
|
|
|
|
|
Resume Next in the Error Label |
|
|
|
|
|
|
|
|
Another method of using the Resume Next statement is to use it in the error label itself. Of course, this is not often done, but it is presented here just for completeness: |
|
|
|
 |
|
|
|
|
Private Sub cmdResumeNext2_Click()
' Delete a file, if it exists. On Error GoTo Error_EH
Stop
Kill txtFileKill
Err.Clear
NormalExit:
Exit Sub
Error_EH: Resume Next End Sub |
|
|
|
|
|
|
|
|
In this code, a normal error trap is set using a label name. Inside of the label, Resume Next is called, and it jumps to the line after the line that has the error. |
|
|
|
|
|
|
|
|
Sometimes youll want to just ignore errors or go to a different location when an error occurs. You should be very careful when using this technique, because you could make your code kind of hard to follow. Figure 17.5 shows the sample that will illustrate this technique. |
|
|
|
|
|
|
|
|
Examples Filename: FileLen.frm |
|
|
|
|
|
|
|
|
Figure 17.5
The Resume to Label and Resume examples. |
|
|
|
|
|